/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package smallcms.util;

import com.google.common.base.Charsets;
import com.google.common.hash.Hashing;
import java.text.MessageFormat;

/**
 *
 * @author hr1ur093
 */
public class Sha256Hash {

    public static void generateHash(String password) {
        
        // This is one way of generating a SHA-256 hash. I uses classes/methods        
        // from the Google Guava project. See the Maven pom.xml file which        
        // I've modified to include the Guava libraries. See the imports        
        // above which show what is being used.        
        String hash = Hashing.sha256().hashString(password, Charsets.UTF_8).toString();        
        String output = MessageFormat.format("{0} hashed to: {1}", password, hash);        
        System.out.println(output); 
    
    } 
    
    public static void main(String[] args) {        

        // you can generate as many as you need ... modify to suite...        
        generateHash("password1");        
        generateHash("password2");        
        generateHash("password3");    
    }
} 
